﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using FluentValidation;
using SilverlightDemo.MonHocServiceReference;

namespace SilverlightDemo.Validators
{

    public class MonHocValidator : AbstractValidator<MonHoc>
    {
        public MonHocValidator()
        {
            RuleFor(x => x.Tenmh).NotEmpty()
                .WithMessage("Không  thể bỏ trống tên môn học");
            RuleFor(x => x.Hocphi)//.GreaterThan(0).WithMessage("Hoc phi phai lon hon 0")
                .NotEmpty().WithMessage("Khong duoc bo trong")
                .Must(BeAValidHocphi).WithMessage("khong duoc <1"); ;                                            
            RuleFor(x => x.Sotc).Must(BeAValidSotc).WithMessage("So tin chi khong hop le");                          
        }
        private bool BeAValidHocphi(int? hocphi)
        {
            if (hocphi == null) return false;
            if (hocphi < 1) return false;
            return true;
        }
        private bool BeAValidSotc(int? sotc)
        {
            if (sotc == null) return false;
            if (sotc < 1) return false;
            //return true;
            return true;
        }
    }
       
}
